# frozen_string_literal: true

# typed: true
# TEAM: growth
module VariableTypesStatus
  CREATED = 'created'
  VALIDATED = 'validated'
  DEPLOYED = 'deployed'

  ALL = {
    CREATED => {
      enum: 1,
      display: 'Created'
    },
    VALIDATED => {
      enum: 2,
      display: 'Validated'
    },
    DEPLOYED => {
      enum: 3,
      display: 'Deployed'
    }
  }.with_indifferent_access

  class << self
    def as_enum
      ALL.transform_values { |v| v[:enum] }
    end

    def display_to_key
      ALL.map { |key, value| [value[:display], key] }.to_h
    end

    def js_constants
      opts = ALL
      opts.each_key do |key|
        val = opts[key]
        val[:name] = key
      end
      { variable_types_status_options: opts }
    end
  end
end
